/**
 */
package com.zbest.zpay.integration.session;

import javax.annotation.Resource;

import com.zbest.component.session.QianSession;
import com.zbest.component.session.RedisSessionRepositoryImpl;
import com.zbest.zpay.integration.aliyun.AliyunOCSClient;

/**
 * 
 *
 * @author czhou3306@gmail.com
 * @version $Id: OCSSessionRepositoryImpl.java, v0.1 2016年2月21日 下午8:18:16 czhou3306@gmail.com Exp $
 */
public class OCSSessionRepositoryImpl extends RedisSessionRepositoryImpl {

    @Resource
    private AliyunOCSClient aliyunOCSClient;

    /** 
     * @see com.duodian.component.session.repository.SessionRepository#save(com.duodian.component.session.QianSession)
     */
    @Override
    public void save(QianSession session) {
        aliyunOCSClient.putData(session.getSessionId(), session, expireTime);
    }

    /** 
     * @see com.duodian.component.session.repository.SessionRepository#getSession(java.lang.String)
     */
    @Override
    public QianSession getSession(String id) {
        return (QianSession) aliyunOCSClient.getData(id);
    }

    /** 
     * @see com.duodian.component.session.repository.SessionRepository#delete(java.lang.String)
     */
    @Override
    public void delete(String id) {
        aliyunOCSClient.remove(id);
    }

    /** 
     * @see com.duodian.component.session.repository.SessionRepository#reclocking(com.duodian.component.session.QianSession)
     */
    @Override
    public void reclocking(QianSession gungunSession) {
        aliyunOCSClient.expire(gungunSession.getSessionId(), expireTime);
    }

    /**
     * Setter method for property <tt>aliyunOCSClient</tt>.
     * 
     * @param aliyunOCSClient value to be assigned to property aliyunOCSClient
     */
    public void setAliyunOCSClient(AliyunOCSClient aliyunOCSClient) {
        this.aliyunOCSClient = aliyunOCSClient;
    }

}
